<?php require_once 'model/user.php'; ?>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="public/style.css">


<div class="page-form">
    <div class="login-form">
        <h1 class="header-form">Login</h1>
        <div class="header-form-description">Don't use Virb yet? <u>Take the tour</u>  or <u>join now</u> </div>
        <form  method="POST">
            
            
            <div id="table_one">
        <table id="table">
            
            
            
          
            <tr>
                <td>Email Address:</td>
                <td> <input id="firstname" type="text" name="username"></td>        
            </tr>
            
             <tr>
                <td>Password:</td>
                <td> <input id="password "type="password" name="password"></td>
             <td><a href="">Forgot your  password</a> </td>
            </tr>
            
             <tr>
                <td></td>
                <td><input type="checkbox"/>remember me this on computer</td>        
             </tr>
            
        </table>
               <div id="aaa"
                <td><input type="submit" id="submit" name="submit" value="Login"></td>
                </div>
            </table>
        </form>
    </div>

    
</div>
    
    <?php if (isset($_POST['submit'])):            ?>
    
        <?php 
                $username = $_POST['username'];
                $password = $_POST['password'];               
                $Yes = FALSE;
                $index1 = -1;
                // dong lenh kiem tra use
                
                for($i = 0 ; $i < count($users) ; $i ++ ) {
                    if ((strcmp($users[$i]['username'], $username )== 0 ) &&
                        (strcmp($users[$i]['password'], $username )== 0 )) {
                        $Yes = TRUE;
                        $index1 = $i;
                    }
                }
                        //xuat hien loi
                if($Yes) {
                    //cau lenh dang nhap thanh cong
                    header("Location: http://localhost/hhhai-web2/index.php?page=1".$users[$index1]['id']);
                } else {
                    echo 'Dang Nhap that bai';
                }
                ?>
    <?php endif; ?>
